﻿<UserControl x:Class="OpenPOS.Infrastructure.Editors.EditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <Grid x:Name="LayoutRoot" Background="{DynamicResource ShadeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="275"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Border Background="{DynamicResource WindowBackgroundBrush}" Grid.Row="0" HorizontalAlignment="Stretch" Grid.ColumnSpan="2" CornerRadius="2,2,2,2">
            <TextBlock Text="{Binding ItemType.Name}" Foreground="{DynamicResource TextBrush}" Margin="3.5,1.5,0,1.5" />            
        </Border>

        <Grid Grid.Row="1" Grid.Column="0" Margin="5,5,5,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="40" />
            </Grid.ColumnDefinitions>
            <TextBox  Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged}" Grid.Column="0" />
            <Button Content="X" Grid.Column="1" Margin="3.5,0,0,0" />            
        </Grid>
        
        <ListBox ItemsSource="{Binding Items}" Grid.Row="2" Grid.Column="0" Margin="5,5,5,5" SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Grid Grid.Row="1" Grid.Column="1" Grid.RowSpan="3" Margin="5,5,5,5">
            <dataForm:DataForm x:Name="df" EditEnded="DataFormEditEnded" CurrentItem="{Binding SelectedItem, Mode=TwoWay}" AutoGeneratingField="DataFormAutoGeneratingField" />    
        </Grid>

        <StackPanel Grid.Row="3" Orientation="Horizontal" Margin="5,0,5,5">
            <Button x:Name="AddButton" Content="Add" MinWidth="71" MinHeight="17" Margin="0,5,8,5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Command="{Binding AddCommand}" />
            <Button x:Name="RemoveButton" Content="Remove" MinWidth="71" MinHeight="17" Margin="0,5,8,5" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Command="{Binding DeleteCommand}" />
        </StackPanel>


    </Grid>
</UserControl>
